import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        int limit = 20000;
        ArrayList<Integer> primes = new ArrayList<>();
        primes.add(2);
        for (int num = 3; num <= limit; num += 2) {
            if (isPrime(num)) {
                primes.add(num);
            }
        }
        for (int i = 0; i < primes.size(); i++) {
            System.out.print(primes.get(i) + "\t");
            if ((i + 1) % 5 == 0) {
                System.out.println();
            }
        }
    }
    public static boolean isPrime(int num) {
        if (num <= 1) return false;
        if (num == 2) return true;
        if (num % 2 == 0) return false;
        for (int i = 3; i <= Math.sqrt(num); i += 2) {
            if (num % i == 0) {
                return false;
            }
        }
        return true;
    }
}